﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace SevenInvaders.LEVEL_CELSO
{
    class Level_Celso
    {
        
        CelsoPlayer celsoPlayer;
        CelsoEnemy celsoEnemy;
        Texture2D background;

        //Barra winxp
        Texture2D bar;
        Texture2D barra;
        Vector2 barPosition = Vector2.Zero;

       //Variaveis de gradade do cenário
        int gravidade = 0;
        int velocidadeY = 5;


        public Level_Celso(ContentManager Content, GameWindow Window)
        {
            background = Content.Load<Texture2D>("LEVEL_CELSO/bgLevel");
            bar = Content.Load<Texture2D>("LEVEL_CELSO/bar");
           // bar = Content.Load<Texture2D>("LEVEL_CELSO/bar");
            celsoPlayer = new CelsoPlayer(Content.Load<Texture2D>("LEVEL_CELSO/texRedplayer"), new Vector2(0, 10), 1, Window, Content); //content
            celsoEnemy = new CelsoEnemy(Content.Load<Texture2D>("LEVEL_CELSO/texRedplayer"), new Vector2(200, 200), Window, Content);

        

       /* mapArray = new int[,]
        {
            {0, 0, 0, 0},
            {2, 0, 0, 2},
            {0, 0, 0, 0},
            {1, 1, 1, 1}
        };

            // Get upper bounds for the mapArray.
            int bound0 = mapArray.GetUpperBound(0);
            int bound1 = mapArray.GetUpperBound(1);

            // Use for-loops to iterate over the mapArray elements.
            for (int i = 0; i <= bound0; i++)
            {
                for (int j = 0; j <= bound1; j++)
                {
                    int value = mapArray[i, j];
                    Console.WriteLine(value);
                }
            }*/
   



        }

        public void Update(GameTime gameTime, KeyboardState teclado, KeyboardState teclado_anterior)
        {
           
           celsoPlayer.Update(gameTime, teclado);
           celsoEnemy.Update(gameTime);

            velocidadeY += gravidade;
          //  CelsoPlayer.Position.Y += velocidadeY;

            if (teclado.IsKeyDown(Keys.N) && !teclado_anterior.IsKeyDown(Keys.N))
            {
                Game1.current_state = Game1.State.LEVEL_JOAO;
            }

            if(celsoPlayer.Collision.Intersects(celsoEnemy.Collision))
            {
                celsoPlayer.Position = new Vector2(200, 200);
            }
        }

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(background, Vector2.Zero, Color.White);
            spriteBatch.Draw(bar, new Vector2(1, 575), Color.White);
          //  spriteBatch.Draw(bar, Vector2.Zero, Color.White);

            celsoPlayer.Draw(gameTime, spriteBatch);
            celsoEnemy.Draw(gameTime, spriteBatch);
        }
    }
}
